rm(list=ls())
# Please set the working directory to the folder where the ReadMe.txt is located.
setwd("/Users/tongtongzhang/Dropbox (IPL)/Job experiment/Replication")
rm(list=ls())
#install.packages("stm")
sapply("stm", require, character.only=TRUE)
load("Data/stm_output.RData")
topic_employers <- c(
"Pharmaceutical, hospital",
"Securities",
"Materials, metallurgical",
"Financial service outsourcing",
"Investment management",
"Real estate",
"Biotech, education",
"Construction",
"Intelligent software",
"University research lab",
"Media, culture, sports",
"IT and electronics R&D")
# Plotting Figure 3
set.seed(1227)
employer_penalty <- estimateEffect(1:12 ~ penalize_disloyal, cont_employers,
metadata=meta_employers, uncertainty="None")
summary(employer_penalty)
#png("Figure3.png", units="in", height=10, width=10, res=240)
par(mar=c(5, 15, 1, 5) + 0.1)
plot(employer_penalty, covariate = "penalize_disloyal",
topics=c(9,7,11,4,12,6,3,8,10,5,1,2),
model = cont_employers, method = "difference", cov.value1 = 1,
cov.value2 = 0,
xlab = "Difference in topic proportions",
main = "", xlim = c(-0.03, 0.03), ylim=c(-0.2,12),
labeltype = "custom",  custom.labels="",
cex.lab=1.3,cex.axis=1.3)
par(las=1)
mtext(topic_employers[c(9,7,11,4,12,6,3,8,10,5,1,2)], line=1,
at=12:1,side=2, adj=1, cex=1.3)
text(-0.033, -0.4, pos=4, expression(italic('Not penalize\nnon-conformity')), cex=1.2)
text(0.033, -0.4, pos=2, expression(italic('Penalize\nnon-conformity')), cex=1.2)
#dev.off()
set.seed(1227)
employer_penalty <- estimateEffect(1:12 ~ penalize_disloyal, cont_employers,
metadata=meta_employers, uncertainty="None")
summary(employer_penalty)
#png("Firm_Penal_NL.png", units="in", height=10, width=10, res=240)
par(mar=c(5, 15, 1, 5) + 0.1)
plot(employer_penalty, covariate = "penalize_disloyal",
topics=c(9,7,11,4,12,6,3,8,10,5,1,2),
model = cont_employers, method = "difference", cov.value1 = 1,
cov.value2 = 0,
xlab = "Difference in topic proportions",
main = "", xlim = c(-0.03, 0.03), ylim=c(-0.2,12),
labeltype = "custom",  custom.labels="",
cex.lab=1.3,cex.axis=1.3)
par(las=1)
mtext(topic_employers[c(9,7,11,4,12,6,3,8,10,5,1,2)], line=1,
at=12:1,side=2, adj=1, cex=1.3)
text(-0.033, -0.4, pos=4, expression(italic('Not penalize\nnon-conformity')), cex=1.2)
text(0.033, -0.4, pos=2, expression(italic('Penalize\nnon-conformity')), cex=1.2)
#dev.off()
set.seed(1227)
employer_penalty <- estimateEffect(1:12 ~ penalize_disloyal, cont_employers,
metadata=meta_employers, uncertainty="None")
summary(employer_penalty)
png("Firm_Penal_NL.png", units="in", height=10, width=10, res=240)
par(mar=c(5, 15, 1, 5) + 0.1)
plot(employer_penalty, covariate = "penalize_disloyal",
topics=c(9,7,11,4,12,6,3,8,10,5,1,2),
model = cont_employers, method = "difference", cov.value1 = 1,
cov.value2 = 0,
xlab = "Difference in topic proportions",
main = "", xlim = c(-0.03, 0.03), ylim=c(-0.2,12),
labeltype = "custom",  custom.labels="",
cex.lab=1.3,cex.axis=1.3)
par(las=1)
mtext(topic_employers[c(9,7,11,4,12,6,3,8,10,5,1,2)], line=1,
at=12:1,side=2, adj=1, cex=1.3)
text(-0.033, -0.4, pos=4, expression(italic('Not penalize\nnon-conformity')), cex=1.2)
text(0.033, -0.4, pos=2, expression(italic('Penalize\nnon-conformity')), cex=1.2)
dev.off()
## Step 5: Esitmate topic prevalance ~ penalty on non-conformity
rm(list=ls())
sapply("stm", require, character.only=TRUE)
load("Data/stm_output.RData")
# Labels of the 12 topics (output of Step 4)
topic_employers <- c(
"Pharmaceutical, hospital",
"Securities",
"Materials, metallurgical",
"Financial service outsourcing",
"Investment management",
"Real estate",
"Biotech, education",
"Construction",
"Intelligent software",
"University research lab",
"Media, culture, sports",
"IT and electronics R&D")
# Plotting Figure 3
set.seed(1227)
employer_penalty <- estimateEffect(1:12 ~ penalize_disloyal, cont_employers,
metadata=meta_employers, uncertainty="None")
summary(employer_penalty)
png("Firm_Penal_NL.png", units="in", height=10, width=10, res=240)
par(mar=c(5, 15, 1, 5) + 0.1)
plot(employer_penalty, covariate = "penalize_disloyal",
topics=c(9,7,11,4,12,6,3,8,10,5,1,2),
model = cont_employers, method = "difference", cov.value1 = 1,
cov.value2 = 0,
xlab = "Difference in topic proportions",
main = "", xlim = c(-0.03, 0.03), ylim=c(-0.2,12),
labeltype = "custom",  custom.labels="",
cex.lab=1.3,cex.axis=1.3)
par(las=1)
mtext(topic_employers[c(9,7,11,4,12,6,3,8,10,5,1,2)], line=1,
at=12:1,side=2, adj=1, cex=1.3)
text(-0.033, -0.4, pos=4, expression(italic('Not penalize\nnon-conformity')), cex=1.2)
text(0.033, -0.4, pos=2, expression(italic('Penalize\nnon-conformity')), cex=1.2)
dev.off()
